<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./lib/vue_2.5.22.js"></script>
    <script src="./lib/vue-router_3.0.2.js"></script>
</head>

<body>
    <pre>
<!-- 再被嵌套的元素父级元素之中，template包裹内容为定义的子组件
然后在组件模板中children:[{}{}]来传递参数 -->
就是在父路由对应的组件，还存在子路由，存在一个父子嵌套的关系
使用方式：子路由在router-link中定义，to属性前面需要跟上父路由
    </pre>
    <div id="app">
        <router-link to="/login">login</router-link>
        <router-link to="/register">register</router-link>
        <router-view></router-view>
    </div>
    <script>
        var Login = {
            template: `
            <h4>登录</h4>
            `
        }
        var Register = {
            template: `
            <div>
            <h4>注册</h4>
            <router-link to="/register/r1">子组件1</router-link>
            <router-link to="/register/r2">子组件2</router-link>
            <router-view></router-view>
            </div>
            `
        }
        var R1 = {
            template: `<h6>子组件1</h6>`
        }
        var R2 = {
            template: `<h6>子组件2</h6>`
        }

        const router = new VueRouter({
            routes: [{
                path: '/',
                redirect: '/login'
            }, {
                path: '/login',
                component: Login
            }, {
                path: '/register',
                component: Register,
                children: [{
                    path: 'r1',
                    component: R1
                }, {
                    path: 'r2',
                    component: R2
                }]
            }]
        })
        var vm = new Vue({
            el: '#app',
            router
        })
    </script>
</body>

</html>